package com.example.conf.controller;



import com.example.conf.model.User;
import com.example.conf.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2021-11-18
 */
@RestController
@RequestMapping("/user/testUser")
public class UserController {
    @Resource
    private IUserService service;

    @PostMapping(value = "/getUser")
    public User getUser(){
        return service.getById(1);
    }

    @PostMapping(value = "/addUser")
    public boolean addUser(){
        User user = new User();
        user.setId(2);
        user.setName("李豪");
        user.setAge(15);
        return service.save(user);
    }
    @PostMapping(value = "/getList")
    public List<User> getList(){
        return service.getList();
    }


}
